local Lua__wuhuhongcha = fk.CreateSkill {

  name = "Lua__wuhuhongcha",

}

local U = require "packages.utility.utility"

Fk:loadTranslationTable{
    ["Lua__wuhuhongcha"] = "午后红茶",
    ["$Lua__wuhuhongcha1"] = "不去晒一发吗？",
    ["$Lua__wuhuhongcha2"] = "这↑里↓",
    [":Lua__wuhuhongcha"] = "准备阶段，你可以与所有角色依次进行谋奕:"..
    "<br>昏睡红茶：其对你造成1点伤害，将武将牌翻至背面朝上；"..
    "<br>软手机：其失去1点体力，你获得其两张牌。",
    ["#wuhuhongcha-choice"] = "午后红茶：请选择一项",
    ["Lua__wuhuhongcha-hunshui"] = "昏睡红茶",
    [":Lua__wuhuhongcha-hunshui"] = "其对你造成1点伤害并翻面",
    ["Lua__wuhuhongcha-ruanshouji"] = "软手机",
    [":Lua__wuhuhongcha-ruanshouji"] = "其失去1点体力，你获得其两张牌。",
    ["Lua__wuhuhongcha-gaihui"] = "你改悔罢！",
    [":Lua__wuhuhongcha-gaihui"] = "防止“昏睡红茶”（对其造成1点伤害然后你翻面）",
    ["Lua__wuhuhongcha-114514"] = "好啊！来啊！",
    [":Lua__wuhuhongcha-114514"] = "防止“软手机”（你失去1点体力，其获得你两张牌）",
}

Lua__wuhuhongcha:addEffect(fk.EventPhaseStart, {
    anim_type = "control",
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(Lua__wuhuhongcha.name) and target == player and
               player.phase == Player.Start
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askToSkillInvoke(player, {skill_name = Lua__wuhuhongcha.name,})
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        -- 与所有其他角色进行红茶盛宴
        for _, p in ipairs(room:getOtherPlayers(player)) do
            local choices = U.doStrategy(room, player, p, {"Lua__wuhuhongcha-hunshui","Lua__wuhuhongcha-ruanshouji"}, {"Lua__wuhuhongcha-gaihui","Lua__wuhuhongcha-114514"}, Lua__wuhuhongcha.name, 1)
            if choices[1] == "Lua__wuhuhongcha-hunshui" and choices[2] ~= "Lua__wuhuhongcha-gaihui" then
                room:damage({
                    from = p,
                    to = player,
                    damage = 1,
                    skillName = Lua__wuhuhongcha.name
                })
                if p.faceup then
                    p:turnOver() 
                end
            elseif choices[1] == "Lua__wuhuhongcha-ruanshouji" and choices[2] ~= "Lua__wuhuhongcha-114514" then
                room:loseHp(p, 1, Lua__wuhuhongcha.name)
                if not p:isNude() then
                    local cards = room:askToChooseCards(player, {
                        min = 2,
                        max = 2,
                        target = p,
                        flag = "he",
                        skill_name = Lua__wuhuhongcha.name,
                    })

                    if #cards > 0 then
                        room:obtainCard(player, cards, false, fk.ReasonPrey)
                    end
                end
            end
        end
    end,
})

return Lua__wuhuhongcha